# Makefile for shared

#CORTINASDK_DIR := $(PDT_APP_DIR)/cs_pon/cortinasdk
LIB_VERMAJOR = 0
LIB_VERMINOR = 1
LIB_FILENAME = libcjson.so
LIB_STATIC   = libcjson.a

LIB_CFLAGS  = $(CFLAGS) -shared -fPIC -I. 
LIB_LDFLAGS = $(LDFLAGS) -Wl,-soname,$(LIB_FILENAME).$(LIB_VERMAJOR).$(LIB_VERMINOR)

CFLAGS	+= -I. $(TARGET_CFLAGS)



#CFLAGS  += -I$(TOPDIR)/switch/sdk/rtcore/include
#CFLAGS  += -I$(TOPDIR)/switch/sdk/rtusr/include
#CFLAGS  += -I$(TOPDIR)/switch/sdk/rtcore/linux
#CFLAGS  += -I$(PDT_APP_DIR)/../sdk/realtek/sdk-1.0.1/include
#CFLAGS  += -I$(SDKDIR)/include


#-I$(TOPDIR)/lib8367m
ALL_SRCS = $(shell find ./ -name \*.c)
#ALL_SRCS += $(shell find ./log -name \*.c)
#ALL_SRCS += $(shell find ./memory -name \*.c)
#ALL_SRCS += $(shell find ./thread -name \*.c)
#ALL_SRCS += $(shell find ./md5 -name \*.c)
#ALL_SRCS += $(shell find ./onumanage -name \*.c)


OBJS += $(ALL_SRCS:.c=.o)

SRCS = $(ALL_SRCS)

HEADERS =

all: shared

$(LIB_OBJS): $(HEADERS)

shared: $(OBJS)
	$(AR) -r $(LIB_STATIC) $(OBJS)
	$(CC) $(SRCS) -fPIC  -shared  $(CFLAGS) -o $(LIB_FILENAME)
	mv $(LIB_STATIC) $(TARGET_DIR)
	mv $(LIB_FILENAME) $(TARGET_DIR)
	
clean:
	rm -fr $(LIB_FILENAME) *.o *.so *.a
	rm -rf ./*.o

install: all
	$(STRIP) $(LIB_FILENAME)
	#install -D $(LIB_FILENAME) $(CONFIG_PREFIX)/usr/lib/
#	$(CROSS_COMPILE)strip $(LIB_FILENAME).$(LIB_VERMAJOR).$(LIB_VERMINOR)
#	install -D $(LIB_FILENAME).$(LIB_VERMAJOR).$(LIB_VERMINOR) $(CONFIG_PREFIX)/usr/lib/$(LIB_FILENAME).$(LIB_VERMAJOR).$(LIB_VERMINOR)

